package cn.kgc.search.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;

/**
 * Created by teacher ZHANG on 2023/2/10
 */
//Document-ES中的一条记录，对应数据库的一行：row
@Document(indexName = "articles")
public class ESArticle {
    //主键
    @Id
    private Integer articleId;
    @Field(type = FieldType.Text, analyzer = "ik_smart")
    private String title;
    @Field(type = FieldType.Text, analyzer = "ik_smart")
    private String content;
    @Field(type = FieldType.Date)
    //LocalDate相比于Date，提供更多的函数方法供使用
    private LocalDate createDate;
    @Field(type = FieldType.Keyword)
    private String image;
    @Field(type = FieldType.Object)
    private ESCategory category;

    public ESArticle() {
    }

    public Integer getArticleId() {
        return articleId;
    }

    public void setArticleId(Integer articleId) {
        this.articleId = articleId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public LocalDate getCreateDate() {
        return createDate;
    }

    public void setCreateDate(LocalDate createDate) {
        this.createDate = createDate;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public ESCategory getCategory() {
        return category;
    }

    public void setCategory(ESCategory category) {
        this.category = category;
    }

    @Override
    public String toString() {
        return "Article{" +
                "articleId=" + articleId +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", createDate=" + createDate +
                ", image='" + image + '\'' +
                ", category=" + category +
                '}';
    }
}
